﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TeenyGrab.Interfaces;
using TeenyGrab.Objects;
using TeenyGrab.Helpers;
using System.Windows.Forms;
using System.Runtime.Serialization;
using System.Drawing;
using System.Xml.Serialization;
using TeenyGrab.Serialization;

namespace TeenyGrab.Inputs
{
    [Serializable]
    public class FullScreenInput : IInput
    {
        public bool Configurable { get { return true; } set { } }

        public SerializableScreen Screen { get; set; }

        public string Name { get { return "Fullscreen"; } set { } }

        public string Description { get { return "Takes a screenshot of one or all screens."; } set { } }

        public FullScreenInput()
        {
            Screen = new SerializableScreen(System.Windows.Forms.Screen.PrimaryScreen);
        }

        public void Configure()
        {
            var config = new ConfigureFullScreenInputWindow(this);
            config.ShowDialog();
        }

        public ImageObject Get()
        {
            var screenCapture = new ScreenCapture();
            var image = null as Image;
            if (Screen.Screen == null)
            {
                image = screenCapture.CaptureAllScreens();
            }
            else
            {
                image = screenCapture.CaptureScreen(Screen.Screen);
            }

            return new ImageObject() { Image = image };
        }
    }
}
